package com.yanqu.road.server.cmd.cookboy.process2.cross;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cookboy.CookBoyProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.activity.cookboy.CookBoyActivityMgr;
import com.yanqu.road.server.manger.activity.cookboy.CookBoyMgr;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

/**
 * @Author : Cxp
 * @Time : 2024-11-29
 * @Description : 同步自动回访结果
 */

@Cmd(code = Protocol.S_CROSS_COOK_BOY2_SYNC_AUTO_JOIN_RESULT, desc = "同步自动回访结果")
public class CrossCookBoy2SyncAutoJoinResultCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        CookBoyProto.CrossCookBoy2SyncAutoJoinResultMsg reqMsg =
                CookBoyProto.CrossCookBoy2SyncAutoJoinResultMsg.parseFrom(packet.getBytes());

        CookBoyProto.CrossCookBoy2AutoJoinInfoMsg autoJoinInfo = reqMsg.getAutoJoinInfo();
        int activityId = autoJoinInfo.getGuestActivityId();
        ActivityInfo activityInfo = CookBoyActivityMgr.getOpenActivityInfo(activityId);
        if (activityInfo == null) {
            return;
        }
        if (packet.getPlayerId() != autoJoinInfo.getGuestId()) {
            return;
        }
        CookBoyMgr.dealAutoJoinResult(activityId, reqMsg);
    }
}
